;(function($){
  $.fn.photoSlide=function(data){
    var s='',c="",timmer,index=data.length-1,zIndex=100;
    var imgbox=$('<div class="slide-imgs">'),
    ctrl=$('<div class="slide-ctrl">')
      .on("mouseenter","b",function(){
        clearTimeout(timmer);
        go(this.innerHTML);
      }).on("mouseleave","b",function(){
        timmer=setTimeout(go,4000);
      }),
    title=$('<div class="slide-title">'),
    ttl=$('<div class="slide-ttl">');
    $.each(data,function(i,o){
      s+='<a style="background-image:url('+o.src+')" href="'+o.link+'"></a>';
      c+='<b>'+i+'</b>';
    })
    imgbox.html(s);
    ctrl.html(c);
    imgbox.add(ttl).add(title).add(ctrl).appendTo(this)
    var img=imgbox.find(">a").css({opacity:0});
    var go=function(n){
      if(n===index) return;
      if(!n){
        n=index++;
      }
      index=n;
      if(n>=data.length) n=index=0;
      ctrl.find(".active").removeClass();
      ctrl.find("b:eq("+n+")").addClass("active");
      img.eq(n).css({zIndex:zIndex++,opacity:0}).stop().animate({opacity:1});
      title.html('<a href="'+data[n].link+'" target="_blank">'+data[n].title+'</a>')
    }
    timmer=setTimeout(go,0);
  };
})(jQuery);
//onload
$(function(){
  //gallery
  $(".cui-photo-slide").photoSlide([
    {title:"基础架构云",src:"images/1.jpg",link:"http://baidu.com"},
    {title:"行业应用云",src:"images/2.jpg",link:"http://baidu.com"}
    ]);
  //tab
  $(".tab").each(function(i,o){
    var rel=$(o).data("action")||"mouseover";
    $(o).on(rel,"a",function(){
      $(o).find(">ul>li.on").removeClass("on");
      $(this).parent().addClass("on");
      var content=$(o).parent().find("> .content").hide();
      var index=$(o).find("a").index(this);
      content.eq(index).show();
      return false;
    });
    $("li.on > a",o)[rel]();
  });
});